<?php 
header("Content-type:text/html;charset=utf-8");
//索引
/*$user1 = array('u01','ZQ1','女','20');
$user1[]='大学';
$user1[10]='自我介绍：';
array_push($user1, 'c01');
$hobby= array('登山','游泳','旅游');
$user1[]=$hobby;
$user1['password']='123';
//var_dump($user1);
foreach($user1 as $key => $value)
{
	if(is_array($value))
		foreach($value as $one => $v)
		{
			echo $v.' ';
		}
	else 
		echo '<p>'.$value.'</p>';
}*/
//关联
/*$user1 = array('uid'=>'u01',
			   'uname'=>'ZQ1',
			   'password'=>'123',
			   'age'=>'20',
			   'gender'=>'女',
			   'degree'=>'大学',
			   'type'=>'c01',
			   'hobby'=>array('登山','游泳','旅游'),
			   'intro'=>'自我介绍' );
foreach ($user1 as $key => $value) {
	echo '<p>';
		if(is_array($value))
			foreach($value as $one => $v)
				echo $one.":".$v.' ';
		else 
			echo $key.":".$value.' ';

		echo '</p>';
}
*/
//二维数组
/*$user1 = array('uname'=>'ZQ1',
			   'gender'=>'女',
			   'age'=>'20',
			   'hobby'=>array('登山','游泳','旅游'),
			   'degree'=>'大学',
			   'type'=>'c01'
			   );
$user2 = array('uname'=>'ZQ2',
			   'gender'=>'女',
			   'age'=>'20',
			   'hobby'=>array('网球','篮球','读书'),
			   'degree'=>'大学',
			   'type'=>'c01'
			   );
$user3 = array('uname'=>'ZQ3',
			   'gender'=>'女',
			   'age'=>'20',
			   'hobby'=>array('登山','网球','排球'),
			   'degree'=>'大学',
			   'type'=>'c02'
			   );
$user4 = array('uname'=>'ZQ4',
			   'gender'=>'女',
			   'age'=>'20',
			   'hobby'=>array('跑步','游泳','乒乓球'),
			   'degree'=>'大学',
			   'type'=>'c02'
			   );

$userarray = array($user1,$user2,$user3,$user4);
echo "<table align='center' border='1'>";
echo "<tr>";
echo "<th>序号</th>";
echo "<th>用户名</th>";
echo "<th>性别</th>";
echo "<th>年龄</th>";
echo "<th>爱好</th>";
echo "<th>学历</th>";
echo "<th>类别</th>";
echo "</tr>";
foreach ($userarray as $key => $user) {
	echo "<tr>";
	echo "<td>".($key+1)."</td>";
	foreach($user as $one => $v)
	{
      echo "<td>";
      if (is_array($v))
      {
      	$v = implode(",", $v);
      }
      echo $v;
      echo "</td>";
	}
	echo "</tr>";
	
}
echo "</table>";*/
//多维



$user1 = array('uname'=>'ZQ1',
			   'gender'=>'女',
			   'age'=>'20',
			   'hobby'=>array('登山','游泳','旅游'),
			   'degree'=>'大学'
			   
			   );
$user2 = array('uname'=>'ZQ2',
			   'gender'=>'女',
			   'age'=>'20',
			   'hobby'=>array('网球','篮球','读书'),
			   'degree'=>'大学'
			   
			   );
$user3 = array('uname'=>'ZQ3',
			   'gender'=>'女',
			   'age'=>'20',
			   'hobby'=>array('登山','网球','排球'),
			   'degree'=>'大学'
			   
			   );
$user4 = array('uname'=>'ZQ4',
			   'gender'=>'女',
			   'age'=>'20',
			   'hobby'=>array('跑步','游泳','乒乓球'),
			   'degree'=>'大学'
			   );
$type1 = array('tname'=>'学生','people'=> array($user1,$user2));
$type2 = array('tname'=>'上班族','people'=> array($user3,$user4));
$type3 = array($type1,$type2);
echo "<table align='center' border='1'>";
echo "<tr>";
echo "<th>类型</th>";
echo "<th>用户名</th>";
echo "<th>性别</th>";
echo "<th>年龄</th>";
echo "<th>爱好</th>";
echo "<th>学历</th>";
echo "</tr>";
foreach ($type3 as $i => $type) {
	foreach ($type['people'] as $j => $user) {

		foreach ($v2 as $k3 => $v3) {
			if(is_array($v3))
				$v=implode(',', $v3);	
			echo "<td>".$v3."</td>";			}

		
	}

	
}
echo "</table>";
 ?>